package cn.fuxue.hrms.web.admin_controller;

import cn.fuxue.hrms.common.entity.Permission;
import cn.fuxue.hrms.service.PermissionService;
import cn.fuxue.hrms.service.impl.PermissionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller()
@RequestMapping("/admin/permission")
public class PermissionController {

    @Autowired
    private PermissionServiceImpl permissionService;

    @GetMapping("/find")
    public String find(Model model) {
        List<Permission> permissionList=permissionService.find();
        model.addAttribute("permissionList", permissionList);
        return "admin/permission_manager";
    }

    @GetMapping("/delete/{id}")
    public String delete(@PathVariable Integer id) {
        permissionService.deleteByPrimaryKey(id);
        return "redirect:/admin/permission/find";
    }
}
